<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<meta name="keywords" content=""/>
	<meta name="description" content=""/>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"/>
	<meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport" />
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
	<meta name="format-detection" content="telephone=no"/>
	<script src="__STATIC__/js/jquery-2.1.4.min.js"></script>
	<link rel="stylesheet" href="__STATIC__/css/common.css">
	<link rel="stylesheet" href="__STATIC__/css/swiper-4.2.2.min.css">
	<script>
	    window.onload = window.onresize =function(){
	    	document.documentElement.style.fontSize = 100/750*document.documentElement.clientWidth + "px";
	    }    
	</script>
</head>
<style>

</style>
<body>
	<div class="warp" style="height: 100%;">
		<p class="api-head">悦动棋牌</p>
		<p class="api-price">￥</p>
		<div class="api-shou">
			<span>收款方</span>
			<span>悦动棋牌</span>
		</div>
		<div class="pay-btn">
			立即支付
		</div>
	</div>
	<ul class="foot">
		<li class="buy"><a href="{:url('index/buycode')}">购买房卡</a></li>
		<li><a href="{:url('index/code')}">我的邀请码</a></li>
		<li><a href="{:url('index/index')}">个人中心</a></li>
		<li><a href="{:url('index/friend')}">我的合伙人</a></li>
		<li><a href="{:url('index/get')}">奖励中心</a></li>
	</ul>
	<script type="text/javascript">
	var type = "{$type}";


	var money = "{$money}";//总金额
	var data = "{$data}";
	var fid = "{$id}";
	console.log(fid);
	if(type == 'tg'){
		//表示是购买的推广码
		$('.api-price').text('￥98')
	}else if(type == 'fk'){
		//表示是购买的推广码
		$('.api-price').text('￥'+money)
	}
	$.post("http://newwechat.crnonline.org/index/index/test",{'data':data},function(result){
		$.post("http://client.rup-china.com/yxzf/index.php/index/pay/get_data",{'data':result,'id':fid},function(result_test){
		   console.log(result_test);
		});   
	});
	//调用微信JS api 支付
	$('.pay-btn').click(function(){
		
		jsApiCall()
	})
	function jsApiCall()
	{
		WeixinJSBridge.invoke(
			'getBrandWCPayRequest',
			{$jsApiParameters},
			function(res){
				//alert(JSON.stringify(res));
				if(res.err_msg == "get_brand_wcpay_request:ok"){
					$.post("http://client.rup-china.com/yxzf/index.php/index/index/get_qrcode_url",function(result){
					    alert(JSON.stringify(result));
					    if(result.code==1){
					    	// location.href = result.img_url
					    	alert('您已经购买成功，请返回查看')
					    }else{
					    	// alert(result.code)
					    }
					  });
						
				}else if(res.err_msg == "get_brand_wcpay_request:cancel"){
					// alert("您确定取消支付吗");
					$('.choose-area').fadeIn()
					$('.alert').show()
					$('.alert p').text('您确定取消支付吗')
				}else{
					// alert("支付失败!err_msg="+res.err_msg);
					$('.choose-area').fadeIn()
					$('.alert').show()
					$('.alert p').text("支付失败! "+res.errMsg)
				}
			}
		);
	}
	function callpay()
	{
		if (typeof WeixinJSBridge == "undefined"){
		    if( document.addEventListener ){
		        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
		        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		    }
		}else{
		    jsApiCall();
		}
	}
	</script>
	
	
	

	
	
</body>
</html>